【例子介绍】
通过手机扫描条形码并发送到电脑端
【相关图片】
【源码结构】
procedure TfxScanBarcode.Paint;
Var
LR,RT,RC,RB,RD:TRectf;
PD:TPathData;
Begin
inherited;
if FIG<>Nil then
Exit;
//画线条
Canvas.Stroke.Kind := TBrushKind.Solid;
Canvas.Stroke.Dash := TStrokeDash.Solid;
Canvas.Stroke.Color := TAlphaColors.Black;
Canvas.Stroke.Thickness := 1;
Canvas.DrawRect(LocalRect,0,0,AllCorners,1);
//画非扫描区
RT:=Rectf(LocalRect.Left,LocalRect.Top,LocalRect.Right,LocalRect.Top LocalRect.Height/3);
RC:=Rectf(LocalRect.Left,LocalRect.Top LocalRect.Height/3,LocalRect.Right,LocalRect.Top LocalRect.Height/3*2);
RB:=Rectf(LocalRect.Left,LocalRect.Top LocalRect.Height/3*2,LocalRect.Right,LocalRect.Bottom);
Canvas.Fill.Color := FNotScanColor;
Canvas.FillRect(RT,0,0,AllCorners,1);
Canvas.FillText(RC,'未开启扫描',False,1,[],TTextAlign.Center,TTextAlign.Center);
Canvas.FillRect(RB,0,0,AllCorners,1);
//画手电筒开关
RD:=Rectf(RB.Left RB.Width/2-WH/2,RB.Top RB.Height/2-WH/2,RB.Left RB.Width/2 WH/2,RB.Top RB.Height/2 WH/2);
PD:=TPathData.Create;
Try
PD.Data:=FTorchModeData.Data;
PD.FitToRect(RD);
if FCC=NIL then
Canvas.Fill.Color:=FTorchModeNotColor
Else
if FCC.TorchMode=TTorchMode.ModeOff then
Canvas.Fill.Color:=FTorchModeOffColor
Else
Canvas.Fill.Color:=FTorchModeOnColor;
Canvas.FillPath(PD,1);
Finally
PD.DisposeOf;
End;
End;
评论